<template>
  <el-dialog :title="title" :visible="visible" :before-close="() => $emit('update:visible', false)">
    <slot name="add"></slot>
    <div slot="footer" class="dialog-footer">
      <slot name="addfooter">
        <el-button @click="$emit('update:visible', false)">取 消</el-button>
        <el-button type="primary" @click="onAddHandler">添加信息</el-button>
      </slot>
    </div>
  </el-dialog>
</template>

<script>
export default {
  name: 'xwDialog',
  props: {
    title: {
      type: String,
      default: '默认标题'
    },
    visible: {
      type: Boolean,
      default: false
    },
    addHandler: {
      type: Function,
      required: true
    }
  },
  methods: {
    onAddHandler() {
      this.addHandler()
    }
  }
}
</script>

<style lang="scss" scoped>
h3 {
  color: red;
}
</style>
